import Vue from 'vue'

//进度条
import "../../node_modules/nprogress/nprogress.css"
import  NProgress  from 'nprogress'
//路由
import VueRouter from 'vue-router'
// //引入 axios
// import axios from 'axios';
// import QS from 'qs'; // 引入qs模块，用来序列化post类型的数据，后面会提到
// // vant的toast提示框组件，大家可根据自己的ui组件更改。
// import { Toast } from 'vant'; 



// import Home from "@/vue/Home.vue"
// import Register from "@/vue/Register.vue"
// import Login from "@/vue/login.vue"
// import Tiyu from "@/vue/Tiyu.vue"
import Address from "@/vue/Address.vue"
import User from "@/vue/user.vue"
import Dingdan from "@/vue/Dingdan.vue"

Vue.use(VueRouter); // 必须安装到Vue框架中

// 创建路由对象，设置路由表信息
// 实现路由懒加载
const router = new VueRouter({
    routes: [{
        path: "/",
        component: () => import( /* webpackChunkName: "mylogin" */ "@/vue/Home")

    },
    {
        path: "/login",

        component: () => import( /* webpackChunkName: "mylogin" */ "@/vue/Login")
    },
    {
        path: "/register",
        component: () => import( /* webpackChunkName: "mylogin" */ "@/vue/register")
    },
    {
        path: "/Tiyu",
        component: () => import( /* webpackChunkName: "mylogin" */ "@/vue/Tiyu")
    },
    {
        path: "/user",
        component: User,
        // 嵌套的子路匹配到的内容显示在父组件的router-view中
        children: [
            { path: "Address", component: Address },
            { path: "Dingdan", component: Dingdan },
            { path: "", component: Dingdan },
        ]
    },
    ]
})

//前导航守卫
router.beforeEach((to,from,next)=>{
    console.log(NProgress)
    NProgress.start();
    next();
})
//后守卫导航
router.afterEach((to, from) => {
    NProgress.done();
  })

export default router;